/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.funmodelling;

import java.util.ArrayList;

/**
 *
 * @author Mustafa Tosun
 */
public class VModel {

    private ArrayList<Slice> _slices;
    private int _noOfSlices;

    public VModel() {
        _slices = new ArrayList<Slice>();
        _noOfSlices = 0;
    }

    public VModel(ArrayList<Slice> slices) {
        _slices = slices;
        _noOfSlices = slices.size();
    }

    public void addSlice(Slice s) {
        _slices.add(s);
        _noOfSlices++;
    }

    public ArrayList<Slice> getSlices() {
        return _slices;
    }

    public ArrayList<Vertex> getMidPoints(){

        ArrayList<Vertex> mList = new ArrayList<Vertex>();

        Slice s;

        for(int i=0; i< _noOfSlices; i++)
        {
            s = _slices.get(i);
            mList.add(s.getMidPoint());
        }
        
        return mList;
    }

    public Vertex getMidPointHavinId(int id) throws PointNotFoundException
    {
        Slice s;
        Vertex v;

        for(int i=0; i< _noOfSlices; i++)
        {
            s = _slices.get(i);
            v = s.getMidPoint();
            if(v.Id == id)
                return v;
        }
        throw new PointNotFoundException();
    }

    public int size()
    {
        return _noOfSlices;
    }
}
